﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data;
using System.Data.SqlClient;

namespace WebApp3
{
    public partial class frmUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                for (int i = 1; i < 79; i++)
                    ddl_face.Items.Add("表情" + i);
                img_face.ImageUrl = "~\\face\\1.gif";
            }
           
            this.lblName.Text = Session["chuandiname"].ToString();
            
        }
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (Session["Theme"] == null)
            {
                Page.Theme = "浅蓝色";
            }
            else if (Session["Theme"] == "浅蓝色")
            {
                Page.Theme = "浅蓝色";
            }
            else if (Session["Theme"] == "绿色")
            {
                Page.Theme = "绿色";
            }
            else if (Session["Theme"] == "黄色")
            {
                Page.Theme = "黄色";
            }
            else
            {
                Page.Theme = "红色";
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            img_face.ImageUrl = "~\\face\\" + (ddl_face.SelectedIndex + 1) + ".gif";

        }

        protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
        {
            
            string strCn = "server=pc.hstc.cn;database=dhd2014112111;uid=2014112111;pwd=19950511";
            SqlConnection cn = new SqlConnection(strCn);
            try
            {
                cn.Open();
                string strSql = "INSERT INTO LyTable  (lyzhuti, lyneirong, lytime, name, face, lyip, id)  VALUES   (N'" + this.txtLyzhuti.Text + "', N'" + this.txtLyneirong.Text + "',N'" + DateTime.Now.ToString() + "',N'" + this.lblName.Text + "',N'" + (ddl_face.SelectedIndex + 1).ToString() + "',N'" + Request.UserHostAddress.ToString() + "', N'" + this.TextBox1.Text + "')";
                SqlCommand cmd = new SqlCommand(strSql, cn);
                int iUpd = cmd.ExecuteNonQuery();
                if (iUpd < 1)
                {
                    this.lblOk.Text = "留言失败！";
                }
                else
                {
                    this.lblOk.Text = "留言成功！";
                }

            }
            catch (Exception ex)
            {
                this.lblOk.Text = ex.Message;
            }
            finally
            {
                cn.Close();
            }
        }

        protected void txtLyneirong_TextChanged(object sender, EventArgs e)
        {

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
           
        }

        protected void ImageButton7_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("frmUserbianjiliuyan.aspx");
        }

       
    }
}